package action;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;

import manager.ComManager;
import manager.ObjectFactory;
import vue.AdminUserForm;
import bean.DeleteUserMessage;
import bean.UserBean;

public class ActionDeleteUser extends AbstractAction{
	
	AdminUserForm _adminUserForm;
		
		public ActionDeleteUser(AdminUserForm adminUserForm)
		{
			super();
			_adminUserForm = adminUserForm;
		}
		
		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			
			UserBean userToDelete = _adminUserForm.getSelectedUser();
			
			ObjectFactory of = new ObjectFactory();
			ComManager com = of.createComManager();
			DeleteUserMessage mOut = of.createDeleteUserMessage();
			DeleteUserMessage mIn ;
		
			mOut.setUser(userToDelete);
			mIn = (DeleteUserMessage)com.sendMessage(mOut);
			
			_adminUserForm.deleteUser(userToDelete);
			
		}

	}
